import 'package:sinosheets/network/api.dart';

class ProductApi {
  /// 获取商品列表
  static Future<dynamic> getProductList([Map<String, dynamic>? params]) {
    return HttpClient().request(
      '/product/linkSheet/pageList',
      HttpMethod.get,
      parameters: params,
    );
  }

  /// 获取是否显示顶部信息
  static Future<dynamic> getShowTopInfo(String? code) {
    return HttpClient().request(
      '/product/linkSheet/showTop',
      HttpMethod.get,
      parameters: {'code': code},
    );
  }

  /// 是否展示分类信息
  static Future<dynamic> getShowCategory(String? code) {
    return HttpClient().request(
      '/product/linkSheet/showCategory',
      HttpMethod.get,
      parameters: {'code': code},
    );
  }

  /// 分类树
  static Future<dynamic> getCategory() {
    return HttpClient().request(
      '/product/sheetCategory/getTreeList',
      HttpMethod.get,
    );
  }

  /// 重点分类
  static Future<dynamic> getCategoryIndexList() {
    return HttpClient().request(
      '/product/sheetCategory/indexList',
      HttpMethod.get,
    );
  }

  /// 获取分类商品列表（不分页）
  static Future<dynamic> getCategoryProductList() {
    return HttpClient().request(
      '/product/linkSheet/categoryProductList',
      HttpMethod.get,
    );
  }

  /// 获取分类商品分页列表
  static Future<dynamic> getCategoryProductPageList([Map<String, dynamic>? params]) {
    return HttpClient().request(
      '/product/linkSheet/categoryProductPageList',
      HttpMethod.post,
      parameters: params,
    );
  }

  /// 获取秒杀商品数据
  static Future<dynamic> getFlashSaleProduct() {
    return HttpClient().request(
      '/product/linkSheet/flashSaleProduct',
      HttpMethod.get,
    );
  }

  /// 解析url
  static Future<dynamic> resolveUrl(String url) {
    return HttpClient().request(
      '/product/item/resolveUrl',
      HttpMethod.get,
      parameters: {'url': url},
    );
  }

  /// 零元购商品列表
  static Future<dynamic> getZeroProductList([Map<String, dynamic>? params]) {
    return HttpClient().request(
      '/product/linkSheet/zeroProductList',
      HttpMethod.get,
      parameters: params,
    );
  }

  /// 零元购与折扣商品列表 product/linkSheet/zeroAndDiscountList
  static Future<dynamic> getZeroAndDiscountProductList([Map<String, dynamic>? params]) {
    return HttpClient().request(
      '/product/linkSheet/zeroAndDiscountList',
      HttpMethod.get,
      parameters: params,
    );
  }

  ///首页店铺数据 /product/linkSheet/frontShopList
  static Future<dynamic> getFrontShopList() {
    return HttpClient().request(
      '/product/linkSheet/frontShopList',
      HttpMethod.get,
    );
  }

  ///店铺分页查询
  static Future<dynamic> getShopPageList([Map<String, dynamic>? params]) {
    return HttpClient().request(
      '/product/linkSheet/shopPageList',
      HttpMethod.post,
      parameters: params,
    );
  }

  ///首页数据新接口  /product/linkSheet/index
  static Future<dynamic> getIndexData() {
    return HttpClient().request(
      '/product/linkSheet/index',
      HttpMethod.get,
    );
  }

  ///获取商品详情 /product/item/detail GET
  static Future<BaseResponse> itemDetail({String url = "", bool refresh = false}) {
    return HttpClient().request(
      "/product/item/detail",
      HttpMethod.get,
      parameters: {
        "url": url,
        'refresh': refresh,
      },
      isShowLoading: true,
    );
  }

  ///获取普货商品列表 /mall/product/pageList Post
  static Future<dynamic> getNomalProductPageList(Map<String, dynamic> params) {
    return HttpClient().request(
      '/mall/productSheet/pageList',
      HttpMethod.post,
      parameters: params,
    );
  }

  ///获取普货分类 /mall/category/list?type=DISCOUNT GET
  static Future<dynamic> getNomalCategoryList() {
    return HttpClient().request(
      '/mall/productSheet/list',
      HttpMethod.get,
    );
  }
}
